<?php
class websiteApp extends core
{
	public function clistAction($arg)
    {
        $websites   = base::init('website')->fetchAll();

        $template   = $this->template();
        $template->assign('websites', $websites);
        $template->display('website_clist.php');
    }
    
	public function indexAction($arg)
	{
		$template	= $this->template();
		$websites	= base::init('website')->fetchAll(array('cid'=>$arg['cid']));

		$template->assign('websites', $websites);
		$template->display('website_index.php');
	}

	public function deleteAction($arg)
	{
		$wid		= explode(',',$arg['wid']);
		base::init()->delete(array('wid'=>$wid));
	}

	public function attributeAction($arg)
	{
		if (!isset($arg['wid'])) error::ParameterErrors('params');

		$website	= base::init('website')->fetchRow(array('wid'=>$arg['wid']));
		$conf_path	= website::getConfPath($website['domain']);

		if (isPost())
		{
			base::init('website')->setConfig($arg,$website['domain']);
            $this->refresh('修改成功',"index.php?m=website&a=attribute&wid={$arg['wid']}");
		}
		
		$attr				= base::init('website')->getConfig($website['domain']);
		$columns			= base::init('column')->fetchAll(array('wid'=>$arg['wid']));
		$columns			= column::listcls($columns, 0);
		$template			= $this->template();
	
		$template->assign('website', $website);
		$template->assign('attr', $attr);
		$template->assign('columns', $columns);
		$template->assign('nowpath',realpath(ROOT));
		$template->display('website_attribute.php');
	}
	
	public function addAction($arg)
	{
		$wid	= base::init('website')->insert($arg);
		$this->refresh('add done', "index.php?m=website&a=attribute&wid=$wid");
	}
}
